package com.sqfw.project.utils;

import com.sqfw.common.utils.StringUtils;

/**
 * sql列的动态排序工具类
 */
public class UpperItemUtils {

    public static String upperName(String order, String prop) {


        String orderBy = "";
        //动态排序相关
        if (StringUtils.isEmpty(prop)) {
            orderBy = "starttime desc";

        } else {
            if ("mainNodename".equals(prop)) {
                prop = "class1";
            }
            if ("childNodeName".equals(prop)) {
                prop = "class2";
            }
            String s = com.sqfw.project.wp.utils.UpperUtils.upperCharToUnderLine(prop);
            if (StringUtils.isEmpty(order) || "descending".contains(order)) {

                orderBy = s + " desc";
            } else {
                orderBy = s;

            }
        }
        return orderBy;

    }

    /**
     *  可收回，审核人
     * @param order
     * @param prop
     * @return
     */
    public static String recoverUpperName(String order, String prop) {


        String orderBy = "";
        //动态排序相关
        if (StringUtils.isEmpty(prop)) {
            orderBy = "time_boundry asc";

        } else {
            if ("mainNodename".equals(prop)) {
                prop = "class1";
            }
            if ("childNodeName".equals(prop)) {
                prop = "class2";
            }
            String s = com.sqfw.project.wp.utils.UpperUtils.upperCharToUnderLine(prop);
            if (StringUtils.isEmpty(order) || "descending".contains(order)) {

                orderBy = s + " desc";
            } else {
                orderBy = s;

            }
        }
        return orderBy;

    }

    public static String upperInfoName(String order, String prop) {


        String orderBy = "";
        //动态排序相关
        if (StringUtils.isEmpty(prop)) {
            orderBy = "info.starttime desc";

        } else {
            if ("mainNodename".equals(prop)) {
                prop = "class1";
            }
            if ("childNodeName".equals(prop)) {
                prop = "class2";
            }
            // 坐席姓名
            if ("initiatorName".equals(prop)) {
                prop = "sender";
            }
            String s = com.sqfw.project.wp.utils.UpperUtils.upperCharToUnderLine(prop);
            if (StringUtils.isEmpty(order) || "descending".contains(order)) {
                if ("issatisfied".equals(s)) {
                    orderBy = "wvi." + s + " desc";
                } else {
                    orderBy = "info." + s + " desc";
                }

            } else {
                if ("issatisfied".equals(s)) {
                    orderBy = "wvi." + s;
                } else {
                    orderBy = "info." + s;
                }
            }
        }
        return orderBy;

    }

    public static String upperHurryInfoName(String order, String prop) {


        String orderBy = "";
        //动态排序相关
        if (StringUtils.isEmpty(prop)) {
            orderBy = "info.starttime desc";

        } else {
            if ("mainNodename".equals(prop)) {
                prop = "class1";
            }
            if ("childNodeName".equals(prop)) {
                prop = "class2";
            }
            String s = com.sqfw.project.wp.utils.UpperUtils.upperCharToUnderLine(prop);
            if (StringUtils.isEmpty(order) || "descending".contains(order)) {
                if (s.contains("hurry")) {
                    orderBy = "info." + s + " desc";
                } else {
                    orderBy = "info." + s + " desc";
                }

            } else {
                if (s.contains("hurry")) {
                    orderBy = "info." + s;
                } else {
                    orderBy = "info." + s;
                }
            }
        }
        return orderBy;

    }

    public static String upperRowItem(String prop) {

        if (StringUtils.isEmpty(prop)) {
            return "info.starttime";
        } else {
            if ("issatisfied".equals(prop)) {
                return "wvi.issatisfied";
            }
            if ("mainNodename".equals(prop)) {

                return "info.class1";
            }
            if ("childNodeName".equals(prop)) {

                return "info.class2";
            }
            if ("wpid".equals(prop)) {
                return "info.starttime";
            } else {
                return "info." + com.sqfw.project.wp.utils.UpperUtils.upperCharToUnderLine(prop);
            }


        }

    }

    public static String upperProcessedRowItem(String prop) {

        if (StringUtils.isEmpty(prop)) {
            return "wp.starttime";
        } else {

            if ("mainNodename".equals(prop)) {

                return "wp.class1";
            }
            if ("childNodeName".equals(prop)) {

                return "wp.class2";
            }
            if ("wpid".equals(prop)) {
                return "wp.starttime";
            } else {
                return "wp." + com.sqfw.project.wp.utils.UpperUtils.upperCharToUnderLine(prop);
            }


        }

    }
}
